package com.account.service.tcc;

import com.seata.api.tcc.AccountTccAction;
import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.BusinessActionContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

/**
 * @作者: 林江
 * @创建时间: 2023/12/10
 * @功能:
 */
@Slf4j
@DubboService
public class TccAccountServiceImpl implements AccountTccAction {

    @Override
    public boolean prepare(BusinessActionContext actionContext, Integer count) {
        log.info("TCC分支事务try阶段。。。");
        log.info("从用户账户中借出。。。。{}，全局事务id: {},分支事务类型：{}", count, RootContext.getXID(), RootContext.getBranchType());
        return true;
    }

    @Override
    public boolean commit(BusinessActionContext actionContext) {
        log.info("TCC分支事务commit阶段。。。");
        return true;
    }

    @Override
    public boolean rollback(BusinessActionContext actionContext) {
        log.info("TCC分支事务rollback阶段。。。");
        return true;
    }
}
